#include <iostream>
using namespace std;


class Line{
//    TMD
//    TMD
//    TMD
    /***
     * 艹，这里Point需要定义在friend ostream &operator<<(ostream& os, const Line::Point& rhs);之前，
     * 因为这个函数使用了内部类，tmd！，以后所有私有放前面，这c艹真是sb
     */
private:
    class Point{
    public:
        Point(int x,int y): _ix(x), _iy(y){}
        friend ostream &operator<<(ostream& os, const Line::Point& rhs);
    private:
        int _ix;
        int _iy;
    };
    Point _pt1;
    Point _pt2;

public:
    Line(int x1, int y1, int x2, int y2): _pt1(x1,y1), _pt2(x2,y2){}
    friend ostream &operator<<(ostream& os, const Line& rhs);
    friend ostream &operator<<(ostream& os, const Line::Point& rhs);


};
/**
 * 使用输出流运算符输出Line对象，访问了Line对象的point成员，所以设Line为友元
 * @param os
 * @param rhs
 * @return
 */
ostream &operator<<(ostream& os, const Line& rhs){
    os << rhs._pt1 << " ---> " << rhs._pt2;
    return os;
}
/**
 * 访问Point私有成员，所以设为Point的友元
 * 在形参中不能直接使用Point要加上类名作用域
 *
 * Point是Line的私有，还需要在Line中声明友元
 * @param os
 * @param rhs
 * @return
 */
ostream &operator<<(ostream& os, const Line::Point& rhs){
    os << "("<< rhs._ix << " " << rhs._iy << ")";
    return os;
}



void test0(){
    cout << sizeof(Line) << endl;
    Line line(0, 0, 1,1);
}

void test1(){
    cout << Line(0, 0, 3,9) << endl;
}

int main() {
    test1();
    return 0;
}
